package com.ruix.app.model;

import android.util.Log;

import com.ruix.app.cache.CacheFactory;
import com.ruix.app.manager.ClientInfo;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by hadexs on 2017/4/14.
 */

public class Classes implements Serializable {
    private String ID;   //圈子ID
    private String name; //圈子名称
    private String icon; //圈子图标
    private String lastPost;  //圈子最后帖子摘要
    private long lastUpdate;  //圈子最后更新时间
    private String status;  //1为开班了，2为进行中,3为结业
    private String type;   //圈子类型  1为班级圈 2 师友圈
    private String introduce; //班级介绍
    private String organization; //圈子机构
    private String barcode; //二维码
    private String classNum; // 班级数
    private String memberNum; // 成员数
    private long news; // 新文章数
    private boolean isOrganizClass;//是否是组织圈子

    private boolean haseNewMessage;

    public Classes parse(JSONObject object) {
        if (object != null) {
            setID(object.optString("id"));
            setName(object.optString("name"));
            setType(String.valueOf(object.optInt("type",1)));
            setStatus(object.optString("status"));
            JSONObject org = object.optJSONObject("organization");
            if (org != null) {
                setOrganization(org.optString("name"));
            }
        }
        return this;
    }


    public boolean isHaseNewMessage() {
        return haseNewMessage; //
    }

    public void setHaseNewMessage(boolean haseNewMessage) {
        this.haseNewMessage = haseNewMessage;
    }


    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getLastPost() {
        return lastPost;
    }

    public void setLastPost(String lastPost) {
        this.lastPost = lastPost;
    }

    public long getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(long lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }

    public String getOrganization() {
        return organization;
    }

    public void setOrganization(String organization) {
        this.organization = organization;
    }


    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public boolean isClassType() {
        return "1".equals(type);
    }

    public String getClassNum() {
        return classNum;
    }

    public void setClassNum(String classNum) {
        this.classNum = classNum;
    }

    public String getMemberNum() {
        return memberNum;
    }

    public void setMemberNum(String memberNum) {
        this.memberNum = memberNum;
    }

    public long getNews() {
        return news;
    }

    public boolean hasNews(){
        return news > 0;
    }

    public void setNews(long news) {
        this.news = news;
    }

    public boolean isOrganizClass() {
        return isOrganizClass;
    }

    public void setOrganizClass(boolean organizClass) {
        isOrganizClass = organizClass;
    }

    //室友圈
    public boolean isTeacherFriendCircle(){
        return "2".equals(type);
    }

    //是否是意见反馈圈子
    public boolean isFeedbackClass() {
        String feedbackcid = ClientInfo.getFeedbackClassID();
        return feedbackcid.equals(ID);
    }


    //    public String getClassStatus(){
//        if ("1".equals(status)){
//            return "开班了";
//        } else if ("2".equals(status)) {
//            return "进行中";
//        } else if ("3".equals(status)) {
//            return "结业";
//        }
//        return "开班了";
//    }




}
